Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: rename --define-process-env-node-env to --config-node-env #4318

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

snitin315
Copy link
Member

@snitin315 snitin315 commented Nov 5, 2024

What kind of change does this PR introduce?
Fix #3503 (comment)

if (typeof options.defineProcessEnvNodeEnv === "string") {
// TODO: This should only set NODE_ENV for the runtime not for the config too. Change this during next breaking change.
process.env.NODE_ENV = options.defineProcessEnvNodeEnv;

Did you add tests for your changes?
Yes
If relevant, did you update the documentation?
Will update in docs website, I have updated the option descriptions.
Summary

#4318 (comment)

Does this PR introduce a breaking change?
Yes

--define-process-env-node-env was removed in favor of --config-node-env option.

Other information
No

@snitin315 snitin315 requested a review from a team as a code owner November 5, 2024 04:09
@snitin315 snitin315 changed the title feat!: differentiate between --node-env and `--define-process-env-n… feat!: differentiate between --node-env and --define-process-env-node-env Nov 5, 2024
@snitin315 snitin315 changed the title feat!: differentiate between --node-env and --define-process-env-node-env feat!: differentiate --node-env and --define-process-env-node-env Nov 5, 2024
} else if (typeof options.nodeEnv === "string") {
const isNodeEnvOptionDefined = typeof options.nodeEnv === "string";
const isDefineProcessEnvNodeEnvOptionDefined =
typeof options.defineProcessEnvNodeEnv === "string";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snitin315 I don't think we need this option anymore anyway. We have - https://github.com/webpack/webpack/blob/main/lib/WebpackOptionsApply.js#L599.

The main problem is that we have two options:

  • --node-env (set process.env.NODE_ENV for webpack.config.js)
  • --optimization-node-env (set process.env.NODE_ENV for runtime)

And that's why they confuse some developers. The names are almost the same, but they do completely different things.

I think the best solution would be to do the following:

  • remove --define-process-env-node-env at all
  • we leave --node-env because it is widely used by many
  • we come up with a new name for the --node-env variable and updates the documentation so that new developers can use it

Shortly --node-env and ---new-name-node-env work and do the same thing, but the documentation will recommend to use a new name.

To be honest I have no ideas for a new name, so I'd be happy to hear any suggestions 😄

Copy link
Member Author

@snitin315 snitin315 Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexander-akait how about --config-node-env or --config-only-node-env?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--config-node-env sounds good

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 👍🏻

@snitin315 snitin315 changed the title feat!: differentiate --node-env and --define-process-env-node-env feat!: rename --define-process-env-node-env to --config-node-env Nov 6, 2024
@snitin315 snitin315 merged commit 6c5bec1 into next Nov 6, 2024
42 checks passed
@snitin315 snitin315 deleted the fix-define-process-env branch November 6, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants